<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>湖北职业技术学院财务信息查询系统 </title>
<LINK href="style/css.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
	function checkForm() {
		var deptId = document.forms[0].deptId.value;

		if (deptId==0) {
			alert("请选择所属部门");
			return false;
		}
		return true;
	}
</script>
</head>
<body>
<html:form action="user.do?method=save" method="post" onsubmit="return checkForm();">
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableline" id="Table3">
    <tr class="m_lef">
      <td height="40" colspan="9" align="center" bgcolor="#ffffff" class="STYLE4">用户管理</td>
    </tr>
    <tr class="m_lef">
      <td height="30" align="right" bgcolor="#ffffff" class="c_title_memed"><font face="宋体">用户姓名：</font></td>
      <td colspan="8" bgcolor="#ffffff">&nbsp;<html:text property="nickname"/></td>
    </tr>
    <tr class="m_lef">
      <td width="45%" height="30" align="right" bgcolor="#ffffff">登录名：</td>
      <td colspan="8" bgcolor="#ffffff">&nbsp;<html:text property="username"/><font color="red">${error }</font></td>
    </tr>
    <tr class="m_lef">
      <td height="30" align="right" bgcolor="#ffffff">密码：</td>
      <td colspan="7" bgcolor="#ffffff">&nbsp;<input type="password" name="password"/>
        </td>
    </tr>
    <tr class="m_lef">
      <td height="30" align="right" bgcolor="#ffffff">重复密码：</td>
      <td colspan="7" bgcolor="#ffffff">&nbsp;<input type="password" name="password2"/>
        </td>
    </tr>
    <tr class="m_lef">
      <td height="30" align="right" bgcolor="#ffffff" class="c_title_memed"><font face="宋体">用户身份：</font></td>
      <td colspan="8" bgcolor="#ffffff">
		<c:if test="${!empty roles}">
		  <c:forEach items="${roles }" var="role">
		  <html:multibox property="roleIds" value="${role.id }"></html:multibox>${role.description}
		  </c:forEach>
		 </c:if>
	  </td>
    </tr>
    <!--  
    <tr class="m_lef">
      <td height="30" align="right" bgcolor="#ffffff" class="c_title_memed"><font face="宋体">所属部门：</font></td>
      <td colspan="8"bgcolor="#ffffff">
      &nbsp;<html:select property="deptId" style="width:155px">
				<html:option value="0">请选择</html:option>
				<c:if test="${!empty deptList}">
					<c:forEach items="${deptList}" var="dept">
						<html:option value="${dept.id}">${dept.deptName}</html:option>
					</c:forEach>
				</c:if>
			</html:select>
	  </td>
    </tr> 
    -->
    <tr>
      <td height="30" colspan="9" align="center" bgcolor="#ffffff" class="c_foot">
        <html:submit value=" 添加 "/>&nbsp;<html:reset value=" 重置 " />&nbsp;&nbsp; </td>
    </tr>
  </table>
  </html:form>
  
  <br />
  <table id="Table4" bordercolor="#ffffff" height="30" cellspacing="1" cellpadding="1" width="80%"
				align="center" bgcolor="#999999" border="1">
    <tr align="center" bgcolor="#ffffff" height="25">
      <td width="25%"><font color="#000000"><b>用户名</b></font></td>
      <td width="25%"><font color="#000000"><b>用户姓名</b></font></td>
      <td width="25%"><font color="#000000"><b>用户身份</b></font></td>
      <td width="25%"><font color="#000000"><b>操作</b></font></td>
    </tr>
    <c:if test="${!empty users}">
		<c:forEach items="${users}" var="user">
         <tr align="center" bgcolor="#f2f2f2" style="BACKGROUND-COLOR: #f2f2f2" onmouseover="this.style.backgroundColor='#FFCC99'"
							onmouseout="this.style.backgroundColor='#f2f2f2'" height="25">
          <td>${user.username }</td>
          <td>${user.nickname }</td>
          <td>
        <c:if test="${!empty user.roles}">
		<c:forEach items="${user.roles}" var="role">
		${role.description }
		</c:forEach>
		</c:if>
          </td>
          <td align="center">
          <a href="user.do?method=toUpdate&id=${user.id }">编辑</a>&nbsp;
          <a href="user.do?method=delete&id=${user.id }">删除</a></td>
        </tr>
        </c:forEach>
     </c:if>
     </table>
</body>
</html>